package controller

import (
	"github.com/gin-gonic/gin"
	"github.com/jmoiron/sqlx"
	"vip_video/configx"
	"vip_video/internal/library"
	"vip_video/models"
)

type VideoCategoryController struct {
	Db     *sqlx.DB
	Config *configx.Config
}

func NewVideoCategoryController() *VideoCategoryController {
	return &VideoCategoryController{}
}

func (vcc *VideoCategoryController) WithDb(db *sqlx.DB) *VideoCategoryController {
	vcc.Db = db
	return vcc
}

func (vcc *VideoCategoryController) WithConfig(config *configx.Config) *VideoCategoryController {
	vcc.Config = config
	return vcc
}

func (vcc *VideoCategoryController) Index(ctx *gin.Context) {
	response := library.NewResponse(ctx)
	var list []*models.VideoCategoryModel
	_ = vcc.Db.Select(
		&list,
		"select * from fa_video_category;",
	)
	response.Success("", list)
}
